package cn.iocoder.yudao.module.biz.dal.mysql.customer.serviceUnit;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.customer.serviceUnit.ServiceUnitDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.customer.serviceUnit.vo.*;

import java.util.List;
import java.util.Map;

/**
 * 客户档案-服务单元管理 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ServiceUnitMapper extends BaseMapperX<ServiceUnitDO> {

    default PageResult<ServiceUnitDO> selectPage(ServiceUnitPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ServiceUnitDO>()
                .likeIfPresent(ServiceUnitDO::getName, reqVO.getName())
                .eqIfPresent(ServiceUnitDO::getBelongDepart, reqVO.getBelongDepart())
                .eqIfPresent(ServiceUnitDO::getServiceType, reqVO.getServiceType())
                .eqIfPresent(ServiceUnitDO::getIsTestUnit, reqVO.getIsTestUnit())
                .eqIfPresent(ServiceUnitDO::getIsReceiveMoney, reqVO.getIsReceiveMoney())
                .eqIfPresent(ServiceUnitDO::getReceiveMoneyType, reqVO.getReceiveMoneyType())
                .eqIfPresent(ServiceUnitDO::getServiceArea, reqVO.getServiceArea())
                .eqIfPresent(ServiceUnitDO::getAddress, reqVO.getAddress())
                .eqIfPresent(ServiceUnitDO::getLng, reqVO.getLng())
                .eqIfPresent(ServiceUnitDO::getLat, reqVO.getLat())
                .betweenIfPresent(ServiceUnitDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ServiceUnitDO::getUpdateTime, reqVO.getUpdateTime())
                .eqIfPresent(ServiceUnitDO::getOwnerUserId, reqVO.getOwnerUserId())
                .orderByDesc(ServiceUnitDO::getId));
    }

    /**
     * 获得简易服务单元管理列表
     *
     * @param pageReqVO 查询条件
     * @return 简易服务单元管理列表
     */
    List<Map<String,Object>> getSimpleList(ServiceUnitPageReqVO pageReqVO);
}